package com.ash.service.advertisement;

import com.ash.domain.Advertisement;
import com.ash.domain.vo.AdvertisementVo;
import com.ash.mapper.advertisement.AdvertisementMapper;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : Chen Chao
 * @encoding : UTF-8
 * @date : 2021/4/1 18:23
 * @file : project06.com.ash.service.advertisement.AdvertisementServiceImpl.java
 * @software : IntelliJ IDEA
 * @since : 1.8
 */
@Service
public class AdvertisementServiceImpl implements AdvertisementService {
    @Resource
    AdvertisementMapper advertisementMapper;
    @Override
    public Integer add(Advertisement advertisement) {
        return advertisementMapper.add(advertisement);
    }

    @Override
    public List<AdvertisementVo> selectByRole(@Nullable Integer rid, @Nullable Integer startPage, @Nullable Integer size) {
        if (startPage != null && size != null) {
            return advertisementMapper.selectByRole((rid!=null&&rid==3)?null:rid,(startPage-1)*size,size);
        }
        else{
            return advertisementMapper.selectByRole(rid,null,null);
        }

    }

    @Override
    public Integer dataCount(Integer rid) {
        return advertisementMapper.dataCount(rid);
    }

    @Override
    public int delete(int aid) {
        return advertisementMapper.delete(aid);
    }

    @Override
    public int deleteByIds(List<Integer> ids) {
        return advertisementMapper.deleteByIds(ids);
    }

}
